@import '../../css/config/index.scss';

.category-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.category-modal {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease;

  .dark_theme & {
    background-color: #2a2a2a;
    color: #fff;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.category-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e0e0e0;

  .dark_theme & {
    border-bottom-color: #444;
  }

  h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #333;

    .dark_theme & {
      color: #fff;
    }
  }
}

.category-modal-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.2s ease;

  &:hover {
    color: #333;
  }

  .dark_theme & {
    color: #aaa;

    &:hover {
      color: #fff;
    }
  }
}

.category-modal-content {
  display: flex;
  gap: 24px;
  padding: 24px;
  flex: 1;
  overflow: visible;
}

.category-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;

  h3 {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;

    .dark_theme & {
      color: #fff;
    }
  }

  h4 {
    margin: 16px 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #666;

    .dark_theme & {
      color: #aaa;
    }
  }
}

.info-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #ccc;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  cursor: help;
  transition: background-color 0.2s ease;

  &:hover {
    background-color: #999;
  }

  .dark_theme & {
    background-color: #555;

    &:hover {
      background-color: #777;
    }
  }
}

.category-modal {
  .available-categories {
    margin-top: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .category-list {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    background-color: #f9f9f9;
    min-height: 100px;

    .dark_theme & {
      background-color: #333;
      border-color: #555;
    }

    &.scrollable {
      max-height: 300px;
      overflow-y: auto;

      &::-webkit-scrollbar {
        width: 8px;
      }

      &::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;

        .dark_theme & {
          background: #2a2a2a;
        }
      }

      &::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 4px;

        &:hover {
          background: #aaa;
        }

        .dark_theme & {
          background: #555;

          &:hover {
            background: #666;
          }
        }
      }
    }
  }

  .category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;

    .dark_theme & {
      background-color: #2a2a2a;
      border-color: #444;
      color: #fff;
    }

    &.clickable {
      cursor: pointer;

      &:hover {
        background-color: #f0f7ff;
        border-color: var(--default-theme-color, #009933);

        .dark_theme & {
          background-color: #3a3a3a;
        }
      }
    }

    &.marked-for-removal {
      background-color: #ffe0e0;
      border-color: #ffaaaa;
      opacity: 0.7;

      .dark_theme & {
        background-color: #4a2a2a;
        border-color: #aa5555;
      }

      span {
        text-decoration: line-through;
      }
    }

    span {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .add-btn,
  .remove-btn {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
  }

  .add-btn {
    color: var(--default-theme-color, #009933);

    &:hover {
      background-color: rgba(0, 153, 51, 0.1);
    }

    .dark_theme & {
      color: #66bb66;

      &:hover {
        background-color: rgba(102, 187, 102, 0.2);
      }
    }
  }

  .remove-btn {
    color: #dc3545;

    &:hover {
      background-color: rgba(220, 53, 69, 0.1);
      color: #c82333;
    }

    .dark_theme & {
      color: #ff6b6b;

      &:hover {
        background-color: rgba(255, 107, 107, 0.2);
        color: #ff8787;
      }
    }
  }

  .empty-message,
  .loading-message {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
    font-style: italic;

    .dark_theme & {
      color: #666;
    }
  }
}

.category-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #e0e0e0;

  .dark_theme & {
    border-top-color: #444;
  }
}

.category-btn {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  &:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
  }
}

.category-btn-cancel {
  background-color: #e0e0e0;
  color: #333;

  &:hover:not(:disabled) {
    background-color: #d0d0d0;
  }

  .dark_theme & {
    background-color: #444;
    color: #fff;

    &:hover:not(:disabled) {
      background-color: #555;
    }
  }
}

.category-btn-proceed {
  background-color: var(--default-theme-color, #009933);
  color: white;

  &:hover:not(:disabled) {
    background-color: var(--default-theme-color, #009933);
    opacity: 0.9;
  }

  .dark_theme & {
    background-color: var(--default-theme-color, #009933);

    &:hover:not(:disabled) {
      background-color: var(--default-theme-color, #009933);
      opacity: 0.9;
    }
  }
}

// Responsive design for smaller screens
@media (max-width: 768px) {
  .category-modal {
    max-width: 95%;
  }

  .category-modal-content {
    flex-direction: column;
    gap: 16px;
  }

  .category-list.scrollable {
    max-height: 150px;
  }
}
